g08cgf
g08cgf
© Numerical Algorithms Group, 2002.
Purpose
2
G08CGF Performs the chi goodness of fit test, for standard
continuous distributions
Synopsis
[chisq,p,ndf,eval,chisqi,ifail] = g08cgf(ifreq,cint,dist,par,npest<,prob,...
ifail>)
Description
2
The (chi) goodness of fit test performed by G08CGF is used to
test the null hypothesis that a random sample arises from a
specified distribution against the alternative hypothesis that
the sample does not arise from the specified distribution.
Given a sample of size n, denoted by x ,x ,...,x , drawn from a
1 2 n
random variable X, and that the data have been grouped into k
classes,
x<=c ,
1
c <x<=c , i=2,3,...k-1,
i-1 i
x>c ,
k-1
2
then the (chi) goodness of fit test statistic is defined by;
2
k (O -E )
2 -- i i
X = > --------
-- E
i=1 i
where O is the observed frequency of the ith class, and E is
i i
the expected frequency of the ith class.
The expected frequencies are computed as
E =p *n,
i i
where p is the probability that X lies in the ith class, that is
i
p =P(X<=c ),
1 1
p =P(c <X<=c ), i=2,3,...k-1,
i i-1 i
p =P(X>c ).
k k-1
These probabilities are either taken from a common probability
distribution or are supplied by the user. The available
probability distributions within this routine are:
2
Normal distribution with mean (mu), variance (sigma) ;
uniform distribution on the interval [a,b];
exponential distribution with probability density function
-(lambda)x
(pdf) = (lambda)e ;
2
(chi) distribution with f degrees of freedom; and
(alpha)-1 -x/(beta)
x e
gamma distribution with pdf = -----------------------------.
(alpha)
(Gamma)((alpha))(beta)
The user must supply the frequencies and classes. Given a set of
data and classes the frequencies may be calculated using G01AEF.
2 2
G08CGF returns the (chi) test statistic, X , together with its
2
degrees of freedom and the upper tail probability from the (chi)
distribution associated with the test statistic. Note that the
2
use of the (chi) distribution as an approximation to the
distribution of the test statistic improves as the expected
values in each class increase.
Parameters
g08cgf
Required Input Arguments:
ifreq (:) integer
cint (:) real
dist (1) string
par (2) real
npest integer
Optional Input Arguments: <Default>
prob (:) real zeros(length(ifreq),1)
ifail integer -1
Output Arguments:
chisq real
p real
ndf integer
eval (:) real
chisqi (:) real
ifail integer